<div class="row-fluid">
    <div class="span12">
        <div class="grid simple">
			<div class="grid-body no-border">
				<style>
					td {
						vertical-align: middle !important;
					}
				</style>

				<form method="post"> 
					<table class="table table-hover no-more-tables">
						<thead>
							<tr>							
								<th>Картинка</th>
								<th>Категория</th>
								<th>Бренд</th>
								<th>Модель</th>
								<th>Картинка</th>
								<th>Категория</th>
								<th>Бренд</th>
								<th>Модель</th>
							</tr>
						</thead>
						<tbody>
							<?php
							$val = 0;
							foreach ($product['h1Title'] as $key => $value):
								?>
								<?php $similarModel = $this->getSimilarModel(strtolower($product['model'][$key]), strtolower($product['brand'][$key]), (isset($product['yaId'][$key]) ? $product['yaId'][$key] : null)); ?>
								<tr>							
									<td><img src="<?php echo $product['mainImageUrl'][$key]; ?>" width="100"><input type="hidden" name="mainImageUrl[<?php echo $val; ?>]" value="<?php echo $product['mainImageUrl'][$key]; ?>"></td>
									<td><?php echo CHtml::dropDownList('category[' . $val . ']', $this->catsReplace[$product['category'][$key]], CHtml::listData(Page::model()->findAll("\"pageType\" = 'category'"), 'pageId', 'pageTitle'), array('empty' => '--')); ?></td>
									<td><?php echo $product['brand'][$key]; ?><input type="hidden" name="brand[<?php echo $val; ?>]" value="<?php echo $product['brand'][$key]; ?>"></td>
									<td style="border-right: 1px dotted #0B9C8F;">
                                                                            <input type="hidden" value="<?php echo trim($product['yaId'][$key]); ?>" name="yaId[<?php echo $val; ?>]">
                                                                            <input type="text" value="<?php echo trim($product['model'][$key]); ?>" name="model[<?php echo $val; ?>]">
                                                                        </td>

									<td><?php echo $similarModel === NULL ? NULL : '<img src="' . Yii::app()->request->baseUrl . '/uploads/images/' . $similarModel->pageType . '/' . $similarModel->pageImages . '" width="100">'; ?></td>
									<td>
										<?php											
										$parentBrand = $similarModel === NULL ? NULL : Page::model()->findByPk($similarModel->pageParent);
										$parentCat = $similarModel === NULL ? NULL : Page::model()->findByPk($parentBrand->pageParent);
										echo $similarModel === NULL ? NULL : $parentCat->pageTitle;
										?>
									</td>									
									<td>
										<input type="hidden" name="modelID[<?php echo $val; ?>]" value="<?php echo $similarModel === NULL ? NULL : $similarModel->pageId; ?>">
										<?php
										echo $similarModel === NULL ? NULL : $parentBrand->pageTitle;
										?>
									</td>
									<td><?php echo $similarModel === NULL ? NULL : $similarModel->pageTitle; ?></td>
								</tr>
								<tr>
									<td>
										<div class="radio radio-success">
											<input type="radio" name="action[<?php echo $val; ?>]" value="update" id="update-<?php echo $val; ?>">
											<label for="update-<?php echo $val; ?>">Обновить</label>											
										</div>										
									</td>
									<td>
										<div class="radio radio-success">
											<input id="add-<?php echo $val; ?>" type="radio" <?php echo $similarModel['pageId'] === NULL ? 'checked=""' : ''; ?> name="action[<?php echo $val; ?>]" value="add">
											<label for="add-<?php echo $val; ?>">Добавить</label>											
										</div>										
									</td>
									<td>
										<div class="radio radio-success">
											<input id="skip-<?php echo $val; ?>" type="radio" <?php echo $similarModel['pageId'] !== NULL ? 'checked=""' : ''; ?> name="action[<?php echo $val; ?>]" value="skip">
											<label for="skip-<?php echo $val; ?>">Пропустить</label>											
										</div>											
									</td>
									<td></td><td></td><td></td><td></td><td></td>
								</tr>
								<?php
								$val++;
							endforeach;
							?>
						</tbody>
					</table>
					<div class="form-actions">
						<button name="yt0" type="submit" class="btn btn-primary btn-large">Сохранить</button>	
					</div>					
				</form>
			</div>
        </div>	
    </div>
</div>
<?php unset(Yii::app()->session['brandsCache']); ?>